/**	@version	1.1
*	@author		Tomas Hubik
*/



#include "init.h"
#include "players.h"
#include "gui.h"
#include "units.h"
#include "widget_score_graph.h"
#include "includes.h"



int main( int argc, char *argv[] )
{
	//for memory leak detection
	//#ifdef _DEBUG
	//	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	//#endif


	QApplication a( argc, argv );

	a.setWindowIcon( QIcon( "AI_Tester.ico" ) );
	
	game_gui* ggui;

	//loading of game parameters
	if ( !parameters::get_instance()->load_parameters( "parameters.ait" ) )
	{
		QMessageBox::critical( 0, "Parameters error", "Error occured when reading application's parameters file!" );
		return 1;
	}
	else
	{
		ggui = game_gui::get_instance();	
		ggui->get_graphics();
		//loading of unit types
		if ( !prototypes::get_instance()->load_types( "unit_types.ait" ) )
		{
			QMessageBox::critical( 0, "Unit typer error", "Error occured when reading unit types file!" );
			return 2;
		}
	}
	
	players::get_instance()->fill_players();	
	ggui->create_gui();
	ggui->g->show();

	return a.exec();
}
